/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * OutputConsole.java
 *
 * Created on 25-oct-2011, 19:16:33
 */

package pfc.gui;

import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.SwingUtilities;

/**
 *
 * @author xandru
 */
public class OutputConsole extends javax.swing.JPanel {

    SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
    /** Creates new form OutputConsole */
    public OutputConsole() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration//GEN-END:variables

    public void log(String mensaje) {
        jTextArea1.append(mensaje + "\n");
    }

    public void logTime(String mensaje) {
        Date date = new Date();

        jTextArea1.append(f.format(date) + " - " + mensaje + "\n");
    }

    public void updateTextArea(final String text) {
         SwingUtilities.invokeLater(new Runnable() {
            public void run() {
             jTextArea1.append(text);
    }
  });
}

}
